package ${package.Controller};

import com.ljm.common.dto.BaseResult;
import com.ljm.common.util.ResultUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import ${cfg.apiPackage}.${entity}Api;
import ${cfg.dtoPackage}.${entity}Dto;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
    * ${table.comment!} 前端控制器
    * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Api("${table.comment!}")
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

    /**
    * ${table.comment!}接口
    */
    @Resource
    private ${entity}Api i${entity}Api;

    @ApiOperation(value="保存${table.comment!}")
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public BaseResult save(@ApiParam(value="${table.comment!}") @RequestBody @Validated ${entity}Dto dto){
        return ResultUtil.success();
    }

    @ApiOperation(value="删除${table.comment!}")
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @ResponseBody
    public BaseResult del(@ApiParam(value="主键") @RequestBody List<Long> ids){
        return ResultUtil.success();
    }

    @ApiOperation(value="获取${table.comment!}")
    @RequestMapping(value = "/getById",method = RequestMethod.GET)
    @ResponseBody
    public BaseResult getById(@ApiParam(value="主键") @RequestParam Long id){
        return ResultUtil.success();
    }

    @ApiOperation(value="分页获取${table.comment!}")
    @RequestMapping(value = "/getByPage",method = RequestMethod.GET)
    @ResponseBody
    public BaseResult getByPage(@ApiParam(value="页码") @RequestParam(defaultValue = "1") Integer pageNo,
                                @ApiParam(value="页大小") @RequestParam(defaultValue = "10") Integer pageSize){
        return ResultUtil.success();
    }
}
</#if>
